package com.woniuxy.credit_loans.staff_dong.controller;


import com.woniuxy.credit_loans.entity.SysRole;
import com.woniuxy.credit_loans.staff_dong.dto.RoleDto;
import com.woniuxy.credit_loans.staff_dong.service.RoleService;
import com.woniuxy.credit_loans.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/roles")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("{empId}")
    public Result selRole(@PathVariable Integer empId){
        List<SysRole> sysRoles = roleService.selAll();
        List<Integer> integers = roleService.selCheck(empId);
        return Result.ok().data("roleList",sysRoles).data("checkList",integers);
    }

    @PostMapping("")
    public Result insert(@RequestBody RoleDto roleDto){
        int i = roleService.insertRole(roleDto);
        return Result.ok();
    }

    @GetMapping("")
    public Result selAll(){
        List<SysRole> sysRoles = roleService.selAll();
        return Result.ok().data("roleList",sysRoles);
    }
}
